function [patterns, solutions, testingPatterns, testingSolutions] = getTrainingData( data )
% GENERATEPATTERNS
%   INPUT:
%       data: variable which is a dataset of values from a f:R2 -> R function.
%
%   OUTPUT:
%       patterns: generated training patterns
%       solutions: desired solution for each training pattern
%       testingPatterns: generated testing patterns
%       testingSolutions: desired solution for each testing pattern

% Genera dos subconjuntos de patrones para entrenamiento (80%) y testeo (20%) que representan bien las particularidades de la superficie.

    filteredData = data;
    testingData = data;
    randomRemove = rand(length(data(:,1,:)), 1);
    condition1 = (abs(data(:,1,:)) <= 1.5 & randomRemove >= 0.2) | (data(:,1,:) >= 0.85*max(data(:,1,:))) | data(:,1,:) <= 0.85*min(data(:,1,:));
    condition2 = (abs(data(:,2,:)) <= 1.5 & randomRemove >= 0.2) | (data(:,2,:) >= 0.85*max(data(:,2,:))) | data(:,2,:) <= 0.85*min(data(:,2,:));
    filteredData = data(condition1 & condition2, :);
    testingData = data(~(condition1 & condition2), :);
    patterns = [filteredData(:, 1, :)';filteredData(:,2,:)'];
    solutions = filteredData(:,3,:)';
    testingPatterns = [testingData(:,1,:)';testingData(:,2,:)'];
    testingSolutions = testingData(:,3,:)';
end
